home *** CD-ROM | disk | FTP | other *** search
/ CICA 1993 April / CICA MS Windows - April 1993.iso / unzipped / misc / iv26_w30 / sources / border.c < prev    next >
C/C++ Source or Header  |  1980-01-03  |  3KB  |  113 lines

  1. /*
  2.  * Copyright (c) 1987, 1988, 1989 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and its
  5.  * documentation for any purpose is hereby granted without fee, provided
  6.  * that the above copyright notice appear in all copies and that both that
  7.  * copyright notice and this permission notice appear in supporting
  8.  * documentation, and that the name of Stanford not be used in advertising or
  9.  * publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.  Stanford makes no representations about
  11.  * the suitability of this software for any purpose.  It is provided "as is"
  12.  * without express or implied warranty.
  13.  *
  14.  * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  19.  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  20.  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  21.  */
  22.  
  23. /*
  24.  * Border implementation.
  25.  */
  26.  
  27. #ifdef _3D
  28. #include <math.h>
  29. #endif
  30. #include <InterViews/border.h>
  31. #include <InterViews/painter.h>
  32. #include <InterViews/shape.h>
  33.  
  34. Border::Border (int t) {
  35.     thickness = t;
  36. }
  37.  
  38. Border::Border (const char* name, int t) {
  39.     SetInstance(name);
  40.     thickness = t;
  41. }
  42.  
  43. Border::Border (Painter* out, int t) : (nil, out) {
  44.     thickness = t;
  45. }
  46.  
  47. void Border::Redraw (Coord x1, Coord y1, Coord x2, Coord y2) {
  48. #ifndef _3D
  49.     output->FillRect(canvas, x1, y1, x2, y2);
  50. #endif
  51. #ifdef _3D
  52.     if (abs(x2-x1)!=1 && abs(y2-y1)!=1)
  53.     { output3D->SetColors3D();
  54.       output3D->UseColor3D(3);
  55.       output3D->FillRect(canvas,x1,y1,x2,y2);
  56.       output3D->Border(canvas,x1,y1,x2,y2,1,min(abs(x2-x1),abs(y2-y1))/2); }
  57. #endif
  58. }
  59.  
  60. HBorder::HBorder (int t) : (t) {
  61.     Init();
  62. }
  63.  
  64. HBorder::HBorder (const char* name, int t) : (name, t) {
  65.     Init();
  66. }
  67.  
  68. HBorder::HBorder (Painter* out, int t) : (out, t) {
  69.     Init();
  70.     Reconfig();
  71. }
  72.  
  73. void HBorder::Init () {
  74.     SetClassName("HBorder");
  75. }
  76.  
  77. void HBorder::Reconfig () {
  78. #ifndef _3D
  79.     shape->height = thickness;
  80. #endif
  81. #ifdef _3D
  82.     shape->height=(thickness>1) ? thickness:0;
  83. #endif
  84.     shape->Rigid(hfil, hfil, 0, 0);
  85. }
  86.  
  87. VBorder::VBorder (int t) : (t) {
  88.     Init();
  89. }
  90.  
  91. VBorder::VBorder (const char* name, int t) : (name, t) {
  92.     Init();
  93. }
  94.  
  95. VBorder::VBorder (Painter* out, int t) : (out, t) {
  96.     Init();
  97.     Reconfig();
  98. }
  99.  
  100. void VBorder::Init () {
  101.     SetClassName("VBorder");
  102. }
  103.  
  104. void VBorder::Reconfig () {
  105. #ifndef _3D
  106.     shape->width = thickness;
  107. #endif
  108. #ifdef _3D
  109.     shape->width=(thickness>1) ? thickness:0;
  110. #endif
  111.     shape->Rigid(0, 0, vfil, vfil);
  112. }
  113.